﻿package {
	
	import com.bit101.components.Panel;
	import com.bit101.components.Text;
	import com.bit101.components.VSlider;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;

	public class console extends Sprite {

		public function console() {
			if (stage)
				onInit();
			else
				addEventListener(Event.ADDED_TO_STAGE, onInit);
		}
		
		private function onInit(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, onInit);
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(Event.RESIZE, onResize);
			
			m_panel = new Panel(stage);
			m_log = new Text(m_panel);
			m_log.y = TAB_HEIGHT;
			m_scroll = new VSlider(m_panel);
			m_scroll.y = TAB_HEIGHT;
			m_scroll.value = 0;
			
			onResize();
		}
		
		private function onResize(e:Event = null):void {
			var w:int = stage.stageWidth, h:int = stage.stageHeight;
			m_panel.setSize(w, h);
			m_log.setSize(w - SCROLL_SIZE, h - TAB_HEIGHT);
			m_scroll.x = w - SCROLL_SIZE;
			m_scroll.setSize(SCROLL_SIZE, h - TAB_HEIGHT);
		}
		
		private var m_panel:Panel;
		private var m_log:Text;
		private var m_scroll:VSlider;
		private var m_tabs:Array/*Button*/ = [ ];
		
		private static const TAB_HEIGHT:int = 24;
		private static const SCROLL_SIZE:int = 16;
		
	}
	
}
